home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / programming / aros / utility / strnicmp.c < prev    next >
C/C++ Source or Header  |  1996-09-13  |  2KB  |  82 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: strnicmp.c,v 1.4 1996/09/13 17:33:30 digulla Exp $
  4.     $Log: strnicmp.c,v $
  5.     Revision 1.4  1996/09/13 17:33:30  digulla
  6.     Use the ToLower function instead of the macro
  7.  
  8.     Revision 1.3  1996/08/13 14:10:31  digulla
  9.     Replaced __AROS_LA by __AROS_LHA
  10.  
  11.     Revision 1.2  1996/08/01 17:41:42  digulla
  12.     Added standard header for all files
  13.  
  14.     Desc:
  15.     Lang: english
  16. */
  17. #include <exec/types.h>
  18. #include <aros/libcall.h>
  19. #include "utility_intern.h"
  20.  
  21. /*****************************************************************************
  22.  
  23.     NAME */
  24.     #include <clib/utility_protos.h>
  25.  
  26.     __AROS_LH3(LONG, Strnicmp,
  27.  
  28. /*  SYNOPSIS */
  29.     __AROS_LHA(STRPTR, string1, A0),
  30.     __AROS_LHA(STRPTR, string2, A1),
  31.     __AROS_LHA(LONG,   length,  D0),
  32.  
  33. /*  LOCATION */
  34.     struct UtilityBase *, UtilityBase, 28, Utility)
  35.  
  36. /*  FUNCTION
  37.     Compares two strings treating lower and upper case characters
  38.     as identical up to a given maximum number of characters.
  39.  
  40.     INPUTS
  41.     string1, string2 - The strings to compare.
  42.     length         - maximum number of characters to compare.
  43.  
  44.     RESULT
  45.     <0  if string1 <  string2
  46.     ==0 if string1 == string2
  47.     >0  if string1 >  string2
  48.  
  49.     NOTES
  50.  
  51.     EXAMPLE
  52.  
  53.     BUGS
  54.  
  55.     SEE ALSO
  56.  
  57.     INTERNALS
  58.  
  59.     HISTORY
  60.  
  61. *****************************************************************************/
  62. {
  63.     __AROS_FUNC_INIT
  64.     UBYTE c1, c2;
  65.  
  66.     /* 0 characters are always identical */
  67.     if(!length)
  68.     return 0;
  69.  
  70.     /* Loop as long as the strings are identical and valid. */
  71.     do
  72.     {
  73.     /* Get characters, convert them to lower case. */
  74.     c1=ToLower (*string1++);
  75.     c2=ToLower (*string2++);
  76.     }while(c1==c2&&c1&&--length);
  77.  
  78.     /* Get result. */
  79.     return (LONG)c1-(LONG)c2;
  80.     __AROS_FUNC_EXIT
  81. } /* Strnicmp */
  82.